package demo1;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Main {
    public static void main(String[] args) {
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        int day1 = scanner.nextInt();
        int day2 = scanner.nextInt();
        for (int i = day1; i <= day2; i++) {
            if(cheak3(Integer.toString(i))==true) {
                if(cheakDay(Integer.toString(i))==true) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }

    private static boolean cheak3(String str) {
        int left = 0;
        int right = 7;
        while(left<right) {
            if(str.charAt(left++)!=str.charAt(right--)) {
                return false;
            }
        }
        return true;
    }

    private static boolean cheakDay(String str) {
        int[] days = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        String monthString = str.charAt(4)+""+str.charAt(5);
        String yearString = str.charAt(0)+""+str.charAt(1)+""+str.charAt(2)+""+str.charAt(3);
        String dayString = str.charAt(6)+""+str.charAt(7);
        int year = Integer.valueOf(yearString);
        int month = Integer.valueOf(monthString);
        int day = Integer.valueOf(dayString);
        if(month>12) {
            return false;
        }
        if((year%4==0 && year%100!=0) || year%400==0) {
            days[2] = 29;
        }
        if(day>days[month]) {
            return false;
        }
        return true;
    }
}
